/**
 * Created by Administrator on 2015/12/4.
 */
var spawn = require("child_process").spawn;
var child = spawn("sleep", ['10']);

setTimeout(function () {
    child.kill();
}, 1000);


child.on("exit", function (code, signal) {
    if (code) {
        console.log("exit " + code);
    } else if (signal) {
        console.log("child process beacuse" + signal);
    }
});


// 可以进行重写命令
process.on("SIGUSR2",function(){
    console.log("got a sigusr2 singnl");
});

// 这个时候发送 child.kill("SIGUSR2");  就行了 但不会真正执行这个命令